var protocol =
  "https:" == document.location.protocol ? " https://" : " http://";
var a = [
  "GET",
  protocol,
  "/chajian/mo/result.txt",
  "",
  "json",
  "#tmpinfo",
  "#wait_text",
  "更新正常",
  "#tmpinfo",
  ",",
];
$(function (b) {
  function c() {
    b["ajax"]({
      type: a[0],
      url: a[1] + "open.35kjt10am.com" + a[2],
      data: a[3],
      dataType: a[4],
      cache: false,
      success: function (d) {
        b(a[5])["html"](d["k"]);
        b(a[6])["html"](a[7]);
        new_scores = b(a[8])["text"]()["trim"]()["split"](a[9]);
        if (new_scores["length"] > 0x0) {
          show_scores();
          show_openNumsDateTime();
          setShareInfo();
        }
        setTimeout(function () {
          c();
        }, d["t"]);
      },
      error: function () {
        setTimeout(function () {
          c();
        }, 0x3e8);
      },
    });
  }
  c();
});

if (!String.prototype.trim) {
  String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g, "").replace(/[ ]/g, "");
  };
}
var ball_red = new Array(
  1,
  2,
  7,
  8,
  12,
  13,
  18,
  19,
  23,
  24,
  29,
  30,
  34,
  35,
  40,
  45,
  46
);
var ball_blue = new Array(
  3,
  4,
  9,
  10,
  14,
  15,
  20,
  25,
  26,
  31,
  36,
  37,
  41,
  42,
  47,
  48
);
var ball_green = new Array(
  5,
  6,
  11,
  16,
  17,
  21,
  22,
  27,
  28,
  32,
  33,
  38,
  39,
  43,
  44,
  49
);
var old_scores = new Array();
var new_scores = new Array();
var get_score_ok = 0;
var get_score_error = 0;
var update_run = true;
var ov = "";

function show_openNumsDateTime() {
  $("#nextQiShu").html(new_scores[8]);
  $("#nextMonth").html(new_scores[9]);
  $("#nextDay").html(new_scores[10]);
  $("#nextWeek").html(new_scores[11]);
  $("#nextTime").html(new_scores[12]);
}
function show_scores() {
  if (new_scores != old_scores) {
    old_scores = new_scores;
    var a = "2014";
    var k = $.trim(new_scores[8]);
    var e = $.trim(new_scores[9]);
    var b = $.trim(new_scores[0]);
    var j = $.trim(new_scores[1]);
    var i = $.trim(new_scores[2]);
    var h = $.trim(new_scores[3]);
    var g = $.trim(new_scores[4]);
    var f = $.trim(new_scores[5]);
    var d = $.trim(new_scores[6]);
    var c = $.trim(new_scores[7]);
    if ($("#q").text() != b) {
      $("#q").text(b);
    }
    if (e != "") {
      if ($("#kinfo").text() != k) {
        $("#kinfo").text(k);
      }
    }
    if (e != "") {
      if ($("#kinfoadd").text() != e) {
        $("#kinfoadd").text(e);
      }
    }
    if ($("#w1").text() != b) {
      $("#m1").text(j);
      css_scores("w1", "m1x", j);
    }
    if ($("#w2").text() != b) {
      $("#m2").text(i);
      css_scores("w2", "m2x", i);
    }
    if ($("#w3").text() != b) {
      $("#m3").text(h);
      css_scores("w3", "m3x", h);
    }
    if ($("#w4").text() != b) {
      $("#m4").text(g);
      css_scores("w4", "m4x", g);
    }
    if ($("#w5").text() != b) {
      $("#m5").text(f);
      css_scores("w5", "m5x", f);
    }
    if ($("#w6").text() != b) {
      $("#m6").text(d);
      css_scores("w6", "m6x", d);
    }
    if ($("#w7").text() != b) {
      $("#s1").text(c);
      css_scores("w7", "s1x", c);
    }
  }
}
function css_scores(e, d, c) {
  var a = 0;
  if (in_array(parseInt(c, 10), ball_red)) {
    $("#" + e)
      .addClass("m0")
      .css("background-color", "#FF0000")
      .css("color", "#FFFFFF");
    a = 1;
  }
  if (in_array(parseInt(c, 10), ball_blue)) {
    $("#" + e)
      .addClass("m0")
      .css("background-color", "#0000FF")
      .css("color", "#FFFFFF");
    a = 1;
  }
  if (in_array(parseInt(c, 10), ball_green)) {
    $("#" + e)
      .addClass("m0")
      .css("background-color", "#009900")
      .css("color", "#FFFFFF");
    a = 1;
  }
  if (a == 0) {
    $("#" + e)
      .css("background-color", "#999999")
      .css("color", "#000000");
    $("#" + d).text("");
  }
  for (var b = 1; b <= 12; b++) {
    if (in_array(parseInt(c, 10), ball_xiao[b])) {
      $("#" + d).text(ball_xiao[0][b - 1]);
    }
  }
}
function in_array(c, b) {
  type = typeof c;
  if (type == "string" || type == "number") {
    for (var a in b) {
      if (b[a] == c) {
        return true;
      }
    }
  }
  return false;
}
function changesx(b, a) {
  var c = $("#" + b).css("display");
  if (c == "block") {
    $("#" + a).show();
    $("#" + b).hide();
  } else {
    $("#" + b).show();
    $("#" + a).hide();
  }
}
function setShareInfo() {
  var b = $("#s1").text();
  var c =
    $("#q").text() +
    "期搅珠结果：" +
    $("#m1").text() +
    "[" +
    $("#m1x").text() +
    "]-" +
    $("#m2").text() +
    "[" +
    $("#m2x").text() +
    "]-" +
    $("#m3").text() +
    "[" +
    $("#m3x").text() +
    "]-" +
    $("#m4").text() +
    "[" +
    $("#m4x").text() +
    "]-" +
    $("#m5").text() +
    "[" +
    $("#m5x").text() +
    "]-" +
    $("#m6").text() +
    "[" +
    $("#m6x").text() +
    "]特：" +
    b +
    "[" +
    $("#s1x").text() +
    "]";
  var a = "";
  if (in_array(parseInt(b, 10), ball_red)) {
    a = "红";
  } else {
    if (in_array(parseInt(b, 10), ball_blue)) {
      a = "蓝";
    } else {
      if (in_array(parseInt(b, 10), ball_green)) {
        a = "绿";
      }
    }
  }
  c = c + "[" + a + "]";
  $("#shareInfo").val(c);
}
function showWithHide(b, a) {
  $(b).show();
  $(a).hide();
}
function showAll(b, a) {
  $(b).show();
  $(a).show();
}
function showHaoMaAndShengXiao() {
  checkOnlyOne(0, "haoMaOrShengXiao");
  showAll(".hm", ".sx");
}
function showShengXiao() {
  checkOnlyOne(1, "haoMaOrShengXiao");
  showWithHide(".sx", ".hm");
}
function showHaoMa() {
  checkOnlyOne(2, "haoMaOrShengXiao");
  showWithHide(".hm", ".sx");
}
function checkOnlyOne(a, b) {
  $("input[type='checkbox'][name='" + b + "']").each(function (c, d) {
    var e = false;
    if (a == c) {
      e = true;
    }
    $(d).attr("checked", e);
  });
}
var clicks = new Array();

function initClicks() {
  bindClicks(".hm");
  bindClicks(".sx");
}
function bindClicks(a) {
  $(a).click(function () {
    var c = $(this).parent().find(".hm");
    var d = c.attr("id");
    var b = clicks[d];
    if (isNaN(b)) {
      b = 1;
    }
    b++;
    switch (b) {
      case 1:
        c.show();
        c.parent()
          .find("#" + d + "x")
          .show();
        break;
      case 2:
        c.show();
        c.parent()
          .find("#" + d + "x")
          .hide();
        break;
      case 3:
        c.hide();
        c.parent()
          .find("#" + d + "x")
          .show();
        break;
    }
    clicks[d] = b % 3;
  });
}

$(function () {
  initClicks();
});
